//
// File: mrdivide.cpp
//
// MATLAB Coder version            : 4.0
// C/C++ source code generated on  : 18-Dec-2020 16:50:24
//

// Include Files
#include "rt_nonfinite.h"
#include "sea_parameter_cal.h"
#include "mrdivide.h"
#include "sea_parameter_cal_emxutil.h"
#include "qrsolve.h"

// Function Definitions

//
// Arguments    : const emxArray_real_T *B
//                emxArray_real_T *y
// Return Type  : void
//
void mrdivide(const emxArray_real_T *B, emxArray_real_T *y)
{
  int i2;
  emxArray_real_T *b_B;
  double X;
  int loop_ub;
  emxArray_real_T *r1;
  if (B->size[0] == 0) {
    i2 = y->size[0] * y->size[1];
    y->size[0] = 1;
    y->size[1] = 0;
    emxEnsureCapacity_real_T1(y, i2);
  } else if (B->size[0] == 1) {
    X = 1.0 / B->data[0] * 6.2831853071795862;
    i2 = y->size[0] * y->size[1];
    y->size[0] = 1;
    y->size[1] = 1;
    emxEnsureCapacity_real_T1(y, i2);
    y->data[0] = X;
  } else {
    emxInit_real_T1(&b_B, 2);
    i2 = b_B->size[0] * b_B->size[1];
    b_B->size[0] = 1;
    b_B->size[1] = B->size[0];
    emxEnsureCapacity_real_T1(b_B, i2);
    loop_ub = B->size[0];
    for (i2 = 0; i2 < loop_ub; i2++) {
      b_B->data[b_B->size[0] * i2] = B->data[i2];
    }

    emxInit_real_T(&r1, 1);
    qrsolve(b_B, r1);
    i2 = y->size[0] * y->size[1];
    y->size[0] = 1;
    y->size[1] = r1->size[0];
    emxEnsureCapacity_real_T1(y, i2);
    loop_ub = r1->size[0];
    emxFree_real_T(&b_B);
    for (i2 = 0; i2 < loop_ub; i2++) {
      y->data[y->size[0] * i2] = r1->data[i2];
    }

    emxFree_real_T(&r1);
  }
}

//
// File trailer for mrdivide.cpp
//
// [EOF]
//
